package com.guchenbo.example.bit;

import com.alibaba.fastjson.serializer.SerializeWriter;
import com.alibaba.fastjson.util.IOUtils;

/**
 * Created by CreGu on 2016/6/14.
 */
public class Test2 {

    public static void main(String[] args) {
        int i = -10;
        byte b = (byte) i;
        System.out.println(i);
        System.out.println(b);
        System.out.println(Integer.toBinaryString(b & 0xff));
        System.out.println(Integer.toBinaryString(b));

        int i2 = 10;
        System.out.println(i2);
        System.out.println((byte) i2);

        System.out.println(Integer.toBinaryString((byte) -130));
        System.out.println(Integer.toBinaryString(126));
        System.out.println(Integer.toBinaryString(-130));

        System.out.println(checkPowerOf2(10));
        System.out.println(checkPowerOf22(10));

        SerializeWriter writer = new SerializeWriter();
        writer.write((String) null);

        System.out.println(writer.toString());

        char[] c = new char[20];
        System.out.println(c);
        String s = "www.yiibai.com";

        s.getChars(4, 10,c, 0);
        System.out.println(c);

        Integer n = 1000;
        System.out.println(IOUtils.stringSize(n));
    }

    private static boolean checkPowerOf22(int i) {
        return (i & (i - 1)) == 0;
    }

    private static boolean checkPowerOf2(int i) {
        return (i % 2) == 0;
    }
}
